package team.bluepen.supermarket.conf;

import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;

import java.io.Serializable;
import java.util.Properties;

/**
 * @author RollW
 */
@ConfigurationProperties(prefix = "kafka")
public class KafkaProperties implements Serializable {
    private final String bootstrapServers;

    @ConstructorBinding
    public KafkaProperties(String bootstrapServers) {
        this.bootstrapServers = bootstrapServers;
    }

    public String getBootstrapServers() {
        return bootstrapServers;
    }

    public Properties toProperties() {
        Properties properties = new Properties();
        properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);

        return properties;
    }
}
